import 'package:json_annotation/json_annotation.dart';

part 'login_param.g.dart';

/// 账号密码登录参数
@JsonSerializable()
class AccountLoginParam {
  /// 账号
  final String account;
  
  /// 密码
  final String password;

  /// 构造函数
  AccountLoginParam({
    required this.account,
    required this.password,
  });

  /// 从 JSON 创建对象
  factory AccountLoginParam.fromJson(Map<String, dynamic> json) =>
      _$AccountLoginParamFromJson(json);

  /// 转换为 JSON
  Map<String, dynamic> toJson() => _$AccountLoginParamToJson(this);
}

/// 登录结果模型
@JsonSerializable()
class LoginResult {
  /// 用户ID
  final int id;
  
  /// 用户名
  final String userName;
  
  /// 登录令牌
  final String token;

  /// 构造函数
  LoginResult({
    required this.id,
    required this.userName,
    required this.token,
  });

  /// 从 JSON 创建对象
  factory LoginResult.fromJson(Map<String, dynamic> json) =>
      _$LoginResultFromJson(json);

  /// 转换为 JSON
  Map<String, dynamic> toJson() => _$LoginResultToJson(this);
}
